package com.meiyu.live.ui.columnfollow;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.meiyu.live.R;
import com.meiyu.live.popj.Assort;
import com.meiyu.live.util.DisplayUtils;

/**
 * Created by zbl on 2016/8/17.
 */
public class ColumnFollowView extends TextView {

    private Assort bean;

    public ColumnFollowView(Context context) {
        super(context);
        init(context);
    }

    public ColumnFollowView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        setTextSize(15);
        int paddingleft = DisplayUtils.dpToPixel(context, 5);
        int paddingtop = paddingleft / 2;
        setPadding(paddingleft, paddingtop, paddingleft, paddingtop);
    }

    public void setData(Assort bean) {
        this.bean = bean;
        update();
    }

    public Assort getData(){
        return bean;
    }

    public void update(){
        if(bean != null){
            setText(bean.getName());
            if(bean.isSelected){
                setTextColor(0xa0000000);
                setBackgroundResource(R.drawable.background_columnfollowview_s);
            }else{
                setTextColor(0x40000000);
                setBackgroundResource(R.drawable.background_columnfollowview_n);
            }
        }
    }
}
